import 'dart:developer';

import 'package:get/get.dart';
import 'package:sports_new/entity/expert/subs_article_entity.dart';
import 'package:sports_new/server/api/expert_api.dart';

import '../../server/api/other_api.dart';

class SubsArticleLogic extends GetxController{
  SubsArticleEntity? data;
  String? tip;
  List<String> info = [];
  int ideaId = Get.arguments ?? 0;

  @override
  void onReady() {
    getData();
    super.onReady();
  }

  Future getData() async{
    data = await ExpertApi.getArticle(Get.arguments);
    var tips = await OtherApi.getAppList("app_res_tips");
    try {
      tip = tips
          ?.firstWhere((element) => element.title == "subs_article")
          .content;
    }catch(e){
      log("no subs_article");
    }
    info = [
      if(data?.publishTime != null)
      "${data?.publishTime}发布",
      if(data?.uv != 0 && data?.uv != null)...[
      " · ",
      "${data?.uv}人感兴趣"
      ]
    ];
    update();
  }
}